package run.bottle.shiro.model.dto;

import lombok.Data;

@Data
public class Result {

    private int code = 200;

    private String msg;

    private Object data;

    public static Result error() {
        return error(500,"未知异常，请联系管理员");
    }

    public static Result error(String msg) {
        return error(500, msg);
    }

    public static Result error(int code, String msg) {
        Result result = new Result();
        result.code = code;
        result.msg = msg;
        return result;
    }

    public static Result ok() {
        Result result = new Result();
        result.msg = "操作成功";
        return result;
    }

    public static Result ok(String msg) {
        Result result = new Result();
        result.msg = msg;
        return result;
    }

    public static Result ok(Object object) {
        Result result = new Result();
        result.data = object;
        return result;
    }

    public static Result ok(int code, String msg) {
        Result result = new Result();
        result.code = code;
        result.msg = msg;
        return result;
    }

    public static Result ok(int code, Object data) {
        Result result = new Result();
        result.code = code;
        result.data = data;
        return result;
    }

    public static Result ok(String msg, Object data) {
        Result result = new Result();
        result.msg = msg;
        result.data = data;
        return result;
    }


}
